import { strip } from 'number-precision'

export const kg2lb = (kg: number) => {
  return strip((((kg * 100 * 11023 + 50000) / 100000) << 1) / 10)
}

export const lb2kg = (lb: number) => {
  return strip((lb * 10000) / 11023 / 2)
}

export const lb2st = (lb: number) => {
  const st = Math.floor(lb / 14)
  return [st, strip(lb - st * 14, 2)]
}

export const lb2stExact = (lb: number) => {
  return strip(lb / 14)
}

export const kg2st = (kg: number) => {
  return lb2st(kg2lb(kg))
}

export const kg2stExact = (kg: number) => {
  return lb2stExact(kg2lb(kg))
}

export const cm2Inch = (cm: number) => {
  return strip(cm / 2.5372).toFixed(2)
}
